package zt.bank.boot.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import zt.bank.boot.pojo.Area;
import zt.bank.boot.pojo.City;
import zt.bank.boot.service.AreaService;
import zt.bank.boot.service.CityService;
import zt.bank.boot.util.PatternUtil;

import java.util.List;

/**
 * @Author 宋伟宁
 * @Date 2023/11/9
 * @Version 1.0
 **/
@RestController
public class JsonController {

    @Resource
    private CityService cityService;

    @Resource
    private AreaService areaService;

    @GetMapping("/isChinese/{name}")
    public boolean isChinese(@PathVariable String  name) {
        return PatternUtil.isChese(name);
    }

    @GetMapping("/isIden/{card}")
    public boolean isIden(@PathVariable String card){
        return PatternUtil.isIden(card);
    }
    @GetMapping("/findCity/{pid}")
    public List<City> findCityById(@PathVariable int pid){
        QueryWrapper<City> wrapper = new QueryWrapper<>();
        //where  pid = 1
        wrapper.eq("pid", pid);
        return  this.cityService.list(wrapper);
    }

    @GetMapping("/findArea/{cid}")
    public List<Area> findAreaById(@PathVariable int cid){
        QueryWrapper<Area> wrapper = new QueryWrapper<>();
        //where  pid = 1
        wrapper.eq("cid", cid);
        return  this.areaService.list(wrapper);
    }



}
